package BinaryTree;

/**
 * @author shy_black
 * @date 2019/3/17 14:08
 * @Description:链式二叉树的基本方法测试
 */
public class test {
    public static void main(String[] args) {
        //创建二叉树
        Node node5 = new Node(5,null,null);
        Node node4 = new Node(4,null,node5);
        Node node3 = new Node(3,null,null);
        Node node7 = new Node(7,null,null);
        Node node6 = new Node(6,null,node7);
        Node node2 = new Node(2,node3,node6);
        Node node1 = new Node(1,node4,node2);

        IBinaryTree btree = new LinkedBinaryTreeImpl(node1);

        //判断二叉树是否为空
        System.out.println(btree.isEmpty());
        //先序遍历--递归  1--4--5--2--3--6--7--
        System.out.println("先序遍历开始。。。");
        btree.preOrderTraverse();
        System.out.println();
        //中序遍历4--5--1--3--2--6--7--
        btree.midOrderTraverse();
        //后序遍历5--4--3--7--6--2--1--
        btree.postOrderTraverse();
        //中序遍历非递归--栈
        btree.midOrderByStack();
        //层次遍历--队列

        //查找指定值
        System.out.println(btree.findKey(7));
        //二叉树高度
        System.out.println(btree.getHeight());
        //节点个数
        System.out.println(btree.size());
    }
}
